<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>学生管理·查看学生</title>
    <link rel="stylesheet" type="text/css" href="/static/css/page/look.css">
</head>
<body>
<div id="popups-window">
    <table>
        <tbody>
        <tr>
            <td>角色</td>
            <td class="user-role-id">角色</td>
        </tr>
        <tr>
            <td>账号</td>
            <td class="account">账号</td>
        </tr>
        <tr>
            <td>姓名</td>
            <td class="name">姓名</td>
        </tr>
        <tr>
            <td>性别</td>
            <td class="gender">性别</td>
        </tr>
        <tr>
            <td>手机</td>
            <td class="phone">手机</td>
        </tr>
        <tr>
            <td>邮箱</td>
            <td class="email">邮箱</td>
        </tr>
        <tr>
            <td>QQ号</td>
            <td class="qq">QQ号</td>
        </tr>
        <tr>
            <td>钉钉</td>
            <td class="dingding">钉钉</td>
        </tr>
        <tr>
            <td>更新时间</td>
            <td class="update-time">更新时间</td>
        </tr>
        <tr>
            <td>创建时间</td>
            <td class="create-time">创建时间</td>
        </tr>
        </tbody>
    </table>
</div>

<script type="application/javascript">
    $(function () {
        // 页面元素
        let id = window.sessionStorage.getItem('lookId');
        let userRoleIdEle = $('#popups-window .user-role-id');
        let accountEle = $('#popups-window .account');
        let nameEle = $('#popups-window .name');
        let genderEle = $('#popups-window .gender');
        let phoneEle = $('#popups-window .phone');
        let emailEle = $('#popups-window .email');
        let qqEle = $('#popups-window .qq');
        let dingdingEle = $('#popups-window .dingding');
        let updateTimeEle = $('#popups-window .update-time');
        let createTimeEle = $('#popups-window .create-time');

        // 初始执行操作
        loadTagData();

        // 加载学生数据
        function loadTagData() {
            // 获取数据
            $.ajax({
                url: `/api/user/look/${id}`,
                type: "GET",
                success: function (res) {
                    if (res.code === 0) {  // 业务层面成功
                        nameEle.text(res.data.userInfo.name);
                        userRoleIdEle.text(res.data.userRole.name);
                        accountEle.text(res.data.account);
                        nameEle.text(res.data.userInfo.name);
                        genderEle.text(res.data.userInfo.gender ? '男' : '女');
                        phoneEle.text(res.data.userInfo.phone);
                        emailEle.text(res.data.userInfo.email);
                        qqEle.text(res.data.userInfo.qq);
                        dingdingEle.text(res.data.userInfo.dingding);
                        updateTimeEle.text(res.data.updateTime);
                        createTimeEle.text(res.data.createTime);
                    } else {
                        $.message({type: 'error', content: res.msg});
                    }
                }
            });
        }
    });
</script>
</body>
</html>